* STATE CODE FOR REPLICATION OF RESULTS FROM GEOFFREY WALLACE "ALLIANCES, INSTITUTIONAL DESIGN, AND THE DETERMINANTS OF MILITARY STRATEGY
*	Version using coding of US and Russian observations for alliance variables to 0 (no alliance).

version 8

* cd " appropriate data directory"

use "alliances.dta", clear

* REGRESSION MODELS TO REPRODUCE RESULTS OF QUANTITATIVE ANALYSIS
*	Note that several robustness checks are included with the code for each respective model.

* set working directory for easier use of outreg to specific file folder
cd "C:\Documents and Settings\HP_Administrator\My Documents\DATA STATA 8\reitermeek_1999\alliances_tables_cmpsreview"


* ANALYSIS USING US/RUSSIAN OBS CODED AS "0"/ALLIANCE RATHER THAN MISSING FOR ALLIANCE VARIABLES.
* Results for TABLE 3

* Model 1: Original final model from Reiter and Meek (their model 3)
probit mandummy polity steel direxp
est store RM
outreg using "alliance_table3.xls", nolabel ctitle(Baseline Model) bfmt(f,e,f,f) se replace
outreg using "alliance_table3_p.xls", nolabel ctitle(Baseline Model) bfmt(f,e,f,f) pvalue replace

*Model 2: Model 2 with overall alliances of US and SU -> using ATOP coding
probit mandummy polity steel direxp allyus_atop1_us0 allyrus_atop1_rus0
outreg using "alliance_table3.xls", nolabel ctitle(US and Russian Alliances) bfmt(f,e,f,f) se append
outreg using "alliance_table3_p.xls", nolabel ctitle(US and Russian Alliances) bfmt(f,e,f,f) pvalue append
est store ally

* Robust check using COW alliance coding
probit mandummy polity steel direxp allyus_cow_us0 allyrus_cow_rus0
* Robust check using ATOP coding where alliance only coded as 1 if offensive or defensive pact; nonaggression, neutrality and consultation pacts are coded as 0.
probit mandummy polity steel direxp allyus_atop2_us0 allyrus_atop2_rus0
* Robust check using COW alliance coding where only defensive pacts considered alliances; nonaggression and consultation pacts coded as 0.
probit mandummy polity steel direxp allyus_cow_def_us0 allyrus_cow_def_rus0


* Model 3: Use the military coordination variables for US and Russian allies (use 2nd version with 4 categorial variables)
probit mandummy polity steel direxp milinst2_us0 milinst2_rus0 
outreg using "alliance_table3.xls", nolabel ctitle(Alliance Institutionalization) bfmt(f,e,f,f) se append
outreg using "alliance_table3_p.xls", nolabel ctitle(Alliance Institutionalization) bfmt(f,e,f,f) pvalue append
est store milinst

* Robust check using 3 category milinst variable -> results are essentially the same
probit mandummy polity steel direxp milinst_us0 milinst_rus0


* Model 4: With institutionaliation dummies (4 categorical coding -> 0 no alliance; 1 low; 2 mid; 3 high -> no alliance is baseline category)
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 lmilinst_us0 hmilinst_rus0 mmilinst_rus0 lmilinst_rus0

* Robust using only mid and high dummies -> results remain the same
*	use this specification since for comparative purposes the N remains the same as in other models.
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 hmilinst_rus0 mmilinst_rus0
outreg using "alliance_table3.xls", nolabel ctitle(Alliance Institutionalization Level Dummies) bfmt(f,e,f,f) se append
outreg using "alliance_table3_p.xls", nolabel ctitle(Alliance Institutionalization Level Dummies) bfmt(f,e,f,f) pvalue append
est store milinst_dum


* MODEL 5 NATO/WARSAW 
probit mandummy polity steel direxp nato_us0 warsaw_rus0 allyus_atop1_nonnato_us0 allyrus_atop1_nonws_rus0
outreg using "alliance_table3.xls", nolabel ctitle(NATO and Warsaw) bfmt(f,e,f,f) se append
outreg using "alliance_table3_p.xls", nolabel ctitle(NATO and Warsaw) bfmt(f,e,f,f) pvalue append
est store natows

* Robust check with alternate coding of Warsaw where Albania 1964 is coded as not a member (formally left in 1968 but de facto broke ties in early 1960s)
*	Note that do not need to change nonws variable since coding identical in both warsaw and warsaw2 specifications
*	Results remain the same
probit mandummy polity steel direxp nato_us0 warsaw2_rus0 allyus_atop1_nonnato_us0 allyrus_atop1_nonws_rus0

* Robust check using offensive and defensive ATOP pacts (atop2)
*	Results not change though nonwarsaw variable dropped because predicts failures perfectly
probit mandummy polity steel direxp nato_us0 warsaw_rus0 allyus_atop2_nonnato_us0 allyrus_atop2_nonws_rus0

* Robust check using COW coding
*	Results remain the same though non-warsaw variable dropped
probit mandummy polity steel direxp  nato_us0 warsaw_rus0 allyus_cow_nonnato_us0 allyrus_cow_nonws_rus0

* Robust check using COW defense pacts as only type of alliance
*	Results remain the same though both non-nato and non-warsaw dropped
probit mandummy polity steel direxp nato_us0 warsaw_rus0 allyus_cow_def_nonnato_us0 allyrus_cow_def_nonws_rus0


* Likelihood ratio tests for all main models
lrtest RM ally
lrtest RM milinst
lrtest RM milinst_dum
lrtest RM natows



*SOME OTHER ROBUSTNESS CHECKS

* Including Germany
*	In all cases the German variable is dropped because predicts failure perfectly (too few allies and little institutionalization)
*	Of the 4 cases of German allianes 1930-1945, 3 are of low institutionalization, 1 is mid, and none are high.
probit mandummy polity steel direxp allyus_atop1_us0 allyrus_atop1_rus0 allyg_atop1
probit mandummy polity steel direxp milinst_us0 milinst_rus0 milinst_g
probit mandummy polity steel direxp milinst2_us0 milinst2_rus0 milinst2_g


* Control for THREATS order to preclude possibility that threat is greater determinant of military strategy choice (re: Reviewer #2 comments)
*	Results for variables of interest generally do not change substantially; threat variables are not consistently significant across specifications.
* Model 1
probit mandummy polity steel direxp borders multmid midpart
outreg using "threat_table0.xls", nolabel ctitle(Baseline Model) bfmt(f,e,f,f) se replace
* Model 2
*	Russian variables become significant just shy of the 5% level (6%)
probit mandummy polity steel direxp allyus_atop1_us0 allyrus_atop1_rus0 borders multmid midpart
outreg using "threat_table0.xls", nolabel ctitle(US and Russian Alliances) bfmt(f,e,f,f) se append
* Model 3
probit mandummy polity steel direxp milinst2_us0 milinst2_rus0 borders multmid midpart
outreg using "threat_table0.xls", nolabel ctitle(Alliance Institutionalization) bfmt(f,e,f,f) se append
* Model 4
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 hmilinst_rus0 mmilinst_rus0 multmid borders midpart
outreg using "threat_table0.xls", nolabel ctitle(Alliance Institutionalization Level Dummies) bfmt(f,e,f,f) se append
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 lmilinst_us0 hmilinst_rus0 mmilinst_rus0 lmilinst_rus0 borders multmid midpart
* Model 5
probit mandummy polity steel direxp nato_us0 warsaw_rus0 allyus_atop1_nonnato_us0 allyrus_atop1_nonws_rus0 borders multmid midpart
outreg using "threat_table0.xls", nolabel ctitle(NATO and Warsaw Pact) bfmt(f,e,f,f) se append


* Another way to evaluate threats is to run analysis using alliance institutionalization as the dependent variable
* Create a DV "hmilinst_0" that is 1 if either hmilinst_us0 or hmilinst_rus0 is 1 and 0 otherwise
probit  hmilinst_0  polity multmid midpart direxp borders steel trpqual
*	Only borders is significant but negative and in opposite than expected direction.
probit  hmilinst_0  polity multmid midpart direxp borders steel trpqual rgdp96pc tpop

* Control for Economic development and Population as requested by Reviewer 3
*	Use GDP/capita in constant 1996 $US (from Gleditsch trade data available from Eugene)
*	Use Population data in thousands from COW capabilities index
*	Note that N=112 only since GDP data have many missing values since data don't begin until post-WWII.
*	General Results: Alliance coefficients in models 2 and 3 no longer significant (though still significant at p<.10) though this may be due in part to 
*		smaller sample size. Despite smaller sample size hmilinst and nato/warsaw remain significant as expect in models 4 and 5. In all models 
*		GDP/capita and population never reach standard levels of statistical significance.
* Model 1
probit mandummy polity steel direxp rgdp96pc tpop
* Model 2
probit mandummy polity steel direxp allyus_atop1_us0 allyrus_atop1_rus0 rgdp96pc tpop
* Model 3
probit mandummy polity steel direxp milinst2_us0 milinst2_rus0 rgdp96pc tpop
* Model 4
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 hmilinst_rus0 mmilinst_rus0 rgdp96pc tpop
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 lmilinst_us0 hmilinst_rus0 mmilinst_rus0 lmilinst_rus0 rgdp96pc tpop
* Model 5
probit mandummy polity steel direxp nato_us0 warsaw_rus0 allyus_atop1_nonnato_us0 allyrus_atop1_nonws_rus0 rgdp96pc tpop


* COUPS: Consider another domestic variable that more directly captures quality of civil-military relations -> number of coups in 25-year period (re: R2)
*	Results: coup slightly negative in expected direction but never statistically significant. Other variables do not change substantially.
* Model 1
probit mandummy polity steel direxp coups
* Model 2
probit mandummy polity steel direxp allyus_atop1_us0 allyrus_atop1_rus0 coups
* Model 3
probit mandummy polity steel direxp milinst2_us0 milinst2_rus0 coups
* Model 4
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 hmilinst_rus0 mmilinst_rus0 coups
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 lmilinst_us0 hmilinst_rus0 mmilinst_rus0 lmilinst_rus0 coups
* Model 5
probit mandummy polity steel direxp nato_us0 warsaw_rus0 allyus_atop1_nonnato_us0 allyrus_atop1_nonws_rus0 coups




* RESULTS FOR TABLE 4 (Using Clarify)-> Predicted Probabilities of maneuver (substantive significance)

* Baseline model
estsimp probit mandummy polity steel direxp, dropsims
setx (polity steel) mean direxp 0
simqi
simqi fd(pr) changex(polity min max)
simqi fd(pr) changex(steel min max)
simqi fd(pr) changex(direxp min max)

setx polity min
simqi
setx polity max
simqi
setx polity mean
setx steel min
simqi
setx steel max
simqi
setx steel mean
setx direxp min
simqi
setx direxp max
simqi


* General alliance model
estsimp probit mandummy polity steel direxp allyus_atop1_us0 allyrus_atop1_rus0, dropsims
setx (polity steel) mean (direxp allyus_atop1_us0 allyrus_atop1_rus0) 0
simqi
simqi fd(pr) changex(polity min max)
simqi fd(pr) changex(steel min max)
simqi fd(pr) changex(direxp min max)
simqi fd(pr) changex(allyus_atop1_us0 min max)
simqi fd(pr) changex(allyrus_atop1_rus0 min max)

setx polity min
simqi
setx polity max
simqi
setx polity mean 
setx steel min
simqi
setx steel max
simqi
setx steel mean 
setx direxp min 
simqi
setx direxp max
simqi
setx direxp 0
setx allyus_atop1_us0 min
simqi
setx allyus_atop1_us0 max
simqi
setx allyus_atop1_us0 0
setx allyrus_atop1_rus0 min
simqi
setx allyrus_atop1_rus0 max
simqi
setx allyrus_atop1_rus0 0


* Institutionalization dummy model
estsimp probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 hmilinst_rus0 mmilinst_rus0, dropsims
setx (polity steel) mean (direxp hmilinst_us0 mmilinst_us0 hmilinst_rus0 mmilinst_rus0) 0
simqi
simqi fd(pr) changex(polity min max)
simqi fd(pr) changex(steel min max)
simqi fd(pr) changex(direxp min max)
simqi fd(pr) changex(hmilinst_us0 min max)
simqi fd(pr) changex(mmilinst_us0 min max)
simqi fd(pr) changex(hmilinst_rus0 min max)
simqi fd(pr) changex(mmilinst_rus0 min max)

setx polity min
simqi
setx polity max
simqi
setx polity mean 
setx steel min
simqi
setx steel max
simqi
setx steel mean 
setx direxp min 
simqi
setx direxp max
simqi
setx direxp 0
setx hmilinst_us0 min
simqi
setx hmilinst_us0 max
simqi
setx hmilinst_us0 0
setx mmilinst_us0 min
simqi
setx mmilinst_us0 max
simqi
setx mmilinst_us0 0
setx hmilinst_rus0 min
simqi
setx hmilinst_rus0 max
simqi
setx hmilinst_rus0 0
setx mmilinst_rus0 min
simqi
setx mmilinst_rus0 max
simqi
setx mmilinst_rus0 0


* NATO Warsaw model
estsimp probit mandummy polity steel direxp nato_us0 warsaw_rus0 allyus_atop1_nonnato_us0 allyrus_atop1_nonws_rus0, dropsims
setx (polity steel) mean (direxp nato_us0 allyus_atop1_nonnato_us0 warsaw_rus0 allyrus_atop1_nonws_rus0) 0
simqi
simqi fd(pr) changex(polity min max)
simqi fd(pr) changex(steel min max)
simqi fd(pr) changex(direxp min max)
simqi fd(pr) changex(nato_us0 min max)
simqi fd(pr) changex(allyus_atop1_nonnato_us0 min max)
simqi fd(pr) changex(warsaw_rus0 min max)
simqi fd(pr) changex(allyrus_atop1_nonws_rus0 min max)

setx polity min
simqi
setx polity max
simqi
setx polity mean 
setx steel min
simqi
setx steel max
simqi
setx steel mean 
setx direxp min 
simqi
setx direxp max
simqi
setx direxp 0
setx nato_us0 min
simqi
setx nato_us0 max
simqi
setx nato_us0 0
setx allyus_atop1_nonnato_us0 min
simqi
setx allyus_atop1_nonnato_us0 max
simqi
setx allyus_atop1_nonnato_us0 0
setx warsaw_rus0 min
simqi
setx warsaw_rus0 max
simqi
setx warsaw_rus0 0
setx allyrus_atop1_nonws_rus0 min
simqi
setx allyrus_atop1_nonws_rus0 max
simqi
setx allyrus_atop1_nonws_rus0 0




* RESULTS FOR PREDICTED VS. ACTUAL VALUES/OUTCOMES-> replication of Table 1a pg.377 with alliance models

*Generate for Model 1 (Reiter and Meek original model 3)
probit mandummy polity steel direxp 

predict prman, pr

*Generate variable to be used as dichotomous for prediction success "prman1"
gen prman1 = 0

*recode prman1 to account for missing values in prman (since there are 3 missing values from 190 sample -> n=183)
recode prman1 0=. if prman==.

*recode prman1 to equal 1 if predicted probability of maneuver is over .5
recode prman1 0=1 if prman>.5

*Provides a cross tab table for predicted and actual strategy choice
tab prman1 mandummy
*According to RM, predict 172 out of 187 cases correctly (0.92)

drop prman prman1


*Generate for MODEL 2 (general alliance variables)
probit mandummy polity steel direxp allyus_atop1_us0 allyrus_atop1_rus0
predict prman, pr
gen prman1 = 0
recode prman1 0=. if prman==.
recode prman1 0=1 if prman>.5
tab prman1 mandummy
drop prman prman1

*Generate for MODEL 3 (Categorial milinst2)
probit mandummy polity steel direxp milinst2_us0 milinst2_rus0
predict prman, pr
gen prman1 = 0
recode prman1 0=. if prman==.
recode prman1 0=1 if prman>.5
tab prman1 mandummy
drop prman prman1


*Generate for MODEL 4 (milinst dummies)
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 hmilinst_rus0 mmilinst_rus0
predict prman, pr
gen prman1 = 0
recode prman1 0=. if prman==.
recode prman1 0=1 if prman>.5
tab prman1 mandummy
*predicts 177 out of 187 cases correctly (0.95) -> 5 more cases than RM
drop prman prman1


*Generate for MODEL 5 (nato and warsaw; non-nato and non-warsaw)
probit mandummy polity steel direxp nato_us0 warsaw_rus0 allyus_atop1_nonnato_us0 allyrus_atop1_nonws_rus0
predict prman, pr
gen prman1 = 0
recode prman1 0=. if prman==.
recode prman1 0=1 if prman>.5
tab prman1 mandummy
drop prman prman1
